package com.anyonavinfo.cpaddemo.data.radioinfo.source;

import com.anyonavinfo.cpaddemo.data.radioinfo.source.local.RadioInfoLocalDataSource;

/**
 * Created by ZuiC on 2017/2/8.
 */

public class RadioInfoRepository implements RadioInfoDataSource {

    private int band = -1;//1 radio 2 phone 3media
    private int fmFrequency = 875;
    private int amFrequency = 531;
    private int volume=15;
    private int mute=0;
    private int voiceChannel = -1;//1 radio 2 phone 3media
    private int radioStation[] = {531,531,531,875,875,875};//Position 1/2/3 4/5/
    private RadioInfoLocalDataSource radioInfoLocalDataSource;

    private static RadioInfoRepository INSTANCE;

    public static RadioInfoRepository getInstance() {
        if (INSTANCE == null) {
            INSTANCE = new RadioInfoRepository();
        }
        return INSTANCE;
    }

    private RadioInfoRepository(){
        radioInfoLocalDataSource = RadioInfoLocalDataSource.getInstance();
    }


    public int[] getRadioStation() {
        return radioStation;
    }

    public void setRadioStation(int position, int frq) {
        radioStation[position]=frq;
    }

    public int getVolume() {
        return volume;
    }

    public void setVolume(int volume) {
        this.volume = volume;
    }

    public int getBand() {
        return band;
    }

    public void setBand(int band) {
        this.band = band;
    }

    public int getMute() {
        return mute;
    }

    public void setMute(int mute) {
        this.mute = mute;
    }

    public int getFmFrequency() {
        return fmFrequency;
    }

    public void setFmFrequency(int fmFrequency) {
        this.fmFrequency = fmFrequency;
    }

    public int getAmFrequency() {
        return amFrequency;
    }

    public void setAmFrequency(int amFrequency) {
        this.amFrequency = amFrequency;
    }

    public int getVoiceChannel() {
        return voiceChannel;
    }

    public void setVoiceChannel(int voiceChannel) {
        this.voiceChannel = voiceChannel;
    }


    @Override
    public void saveRadioStation(int position, int frq) {
        radioInfoLocalDataSource.saveRadioStation(position, frq);
    }

    @Override
    public void loadRadioStation(final LoadRadioStation callBack) {
        radioInfoLocalDataSource.loadRadioStation(new LoadRadioStation() {
            @Override
            public void onLoadRadioStation(int[] radioStation) {
                callBack.onLoadRadioStation(radioStation);
            }
        });
    }
}
